package com.zggk.iroad.diease.dieaselist;

import com.alibaba.fastjson.JSON;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.zggk.iroad.api.MyAppliCation;
import com.zggk.iroad.api.Urls;
import com.zggk.iroad.mvp.BasePresenterImpl;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class DieaseListPresenter extends BasePresenterImpl<DieaseListContract.View> implements DieaseListContract.Presenter{
    @Override
    public void testinfo(String TIME, int PAGEINDEX) {
        String TIME1=TIME.replace("年","-");
        String TIME2=TIME1.replace("月","-");
        String TIME3=TIME2.replace("日","");
        OkGo.<String>get(Urls.YNIP + "QueryBhList")
                .params("DCSJ", "")
                .params("gydwid", MyAppliCation.spUtils.getString("GydwId"))
                .params("orderby", "")
                .params("pageSize", "20")
                .params("pageIndex", PAGEINDEX)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        if (mView == null)
                            return;
                        DiseaseListbean videoVos = JSON.parseObject(response.body(), DiseaseListbean.class);
                        if (videoVos.getState().equals("1")){
                            mView.getData(videoVos);
                        }
                    }
                });
    }
    @Override
    public void deleteById(String guid) {
        OkGo.<String>post(Urls.YNIP + "DeleteBH")
                .params("BHID", guid)
                .execute(new StringCallback(){
                    @Override
                    public void onSuccess(Response<String> response) {
                        mView.deleteByIds();
                    }
                });
    }
}
